<template>
	<view>
		<!-- 顶部导航栏 -->
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 common-title">{{ lang_personal.noteManager }}</view>
				<view></view>
			</view>

			<!-- 分割线 -->
			<u-gap height="1" bgColor="rgba(0, 0, 0, 0.07)"></u-gap>
		</view>

		<!-- 列表 -->
		<view>
			<mescroll-body height="calc(100vh - 98rpx - var(--status-bar-height))" ref="mescrollRef"
				@init="mescrollInit" @down="downCallback" @up="upCallback">
				<view style="padding: 0 30rpx;">
					<view v-for="(item, index) in dataList" :key="index" class="u-m-t-36"
						>
						<view class="flex-center-between">
							<view class="flex-center">
								<view class="u-avatar-60 clear-flex" style="width: 110rpx; height: 110rpx;">
									<x-image :src="showImage(item.avatar, 'logo')" preview></x-image>
								</view>
								<view class="flex-between flex-column" style="padding: 12rpx 18rpx;">
									<view>{{ item.nick || '' }}</view>
									<view class="u-m-t-10 flex-center color-grew u-f-28 u-lh-40">{{ item.createTime || '' }}</view>
								</view>
							</view>
							<view style="width: 80rpx;" class="u-text-center" >
								<u-icon name="liked-active" custom-prefix="u"
									:color="item.likeActionId ? likedColor : defaultColor" size="38">
								</u-icon>
								<view class="u-f-26 u-lh-36 u-m-t-2 nowrap" style="color: #707071">
									{{ formatNumber(item.likeCount || 0) }}</view>
							</view>
						</view>
						<view class="u-m-t-18 u-f-28 u-lh-40 linecamp-2" @click="jumpUrl(`/pages/other/comment/note?notesId=${ item.notesId }&type=shop`)">{{ item.content || '' }}</view>
					</view>

					<!-- 留空 -->
					<view style="height: 200rpx;"></view>
				</view>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import waterfall from '@/utils/waterfall.js'
	import {
		notesPage
	} from '@/api/merchant/note.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				dataList: []
			}
		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				let node = this.$refs['mescrollRef']
				notesPage({
					pageNumber: page.num,
					pageSize: page.size
				}).then(res => {
					node && node.mescroll.endSuccess(res.list.length);
					if (page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(res.list); //追加新数据
				}).catch(() => {
					node && node.mescroll.endErr();
				})
			},
			downCallback() {
				let node = this.$refs['mescrollRef']
				node && node.mescroll.resetUpScroll()
			},
		}
	}
</script>

<style scoped lang="scss">

</style>
